import request from '@/utils/request'
export const getRoleListApi = (params) => request({
  url: '/sys/role',
  method: 'get',
  params
})

export const addRoleApi = (data) => request({
  method: 'post',
  url: '/sys/role',
  data
})

/**
 * 更新角色
 * ***/
export function updateRoleApi(data) {
  return request({
    url: `/sys/role/${data.id}`,
    method: 'put',
    data
  })
}

/** *
 * 删除角色
 * **/
export function delRoleApi(id) {
  return request({
    url: `/sys/role/${id}`,
    method: 'delete'
  })
}

/**
 * 获取可用的角色
 * **/

export function getEnableRoleListApi() {
  return request({
    url: '/sys/role/list/enabled'
  })
}

/**
 * 分配员工角色
 * ***/
export const assignRoleApi = data => request({
  url: '/sys/user/assignRoles',
  method: 'put',
  data
})

// 获取角色详情
export const getRoleDetailApi = id => request({
  url: `/sys/role/${id}`
})
/**
 * 给角色分配权限
 *
 * ***/

export function assignPermApi(data) {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}
